from location.models import Location, Mine
from django.contrib.gis.utils import LayerMapping
from django.contrib.gis.gdal import DataSource
from django.contrib.gis.models import SpatialRefSys

ds = DataSource('data/mineplant.shp')
mapping = {
  'commodity' : 'COMMODITY',
  'name' : 'SITE_NAME',
  'company' : 'COMPANY_NA',
  'county' : 'COUNTY',
  'plant_min' : 'PLANT_MIN',
  'coordinates' : 'POINT'}
srs = SpatialRefSys.objects.get(srid=4326)
lm = LayerMapping(Mine, ds, mapping, source_srs=srs)
lm.save(verbose=True)
